<template>
  <view class="mine">
    <view class="mineBg">
      <image class="mineBg-img" src="../../static/images/mine.png" mode=""></image>
      <view class="mineBg-info">
        <image class="avatar" :src="userInfo.avatar?userInfo.avatar:'../../static/images/logo.jpg'" mode="">
        </image>
        <view class="nikename">{{userInfo.name}}</view>
        <view class="moblie">
          {{userInfo.phone?userInfo.phone:''}}
        </view>
      </view>
    </view>
    <view style="padding: 0 30rpx;box-sizing: border-box;">
      <view class="mineInfo">

        <block v-for="(item, index) in settingList" :key="index">
          <view class="mineInfo-item" v-if="!item.hidden" @click="toPage(item)">
            <image class="img1" :src="item.url" mode=""></image>
            <view class="label">{{item.name}}</view>
            <image class="img2" src="../../static/images/arrow.png" mode=""></image>
          </view>
        </block>

      </view>
      <view style="width: 100%;height: 30rpx;"></view>
    </view>
    <uv-modal ref="modal" title="是否退出登录?" :showCancelButton="true" @confirm="confirm"></uv-modal>
    <Tabbar :selectedIndex="1"></Tabbar>
  </view>
</template>

<script>
  import reqApi from "../../api/api.js";
  export default {
    data() {
      return {
        settingList: [
          {
            url: "../../static/images/s1.png",
            name: "个人信息",
            path: "/pages/mine/userInfo",
          },
          {
            url: "../../static/images/s2.png",
            name: "成员管理",
            path: "/pages/home/sellerList",
            hidden: true
          },
          // {
          //   url: "../../static/images/s2.png",
          //   name: "我的钱包",
          //   path: "/pages/mine/myWallet"
          // },
          // {
          //   url: "../../static/images/s3.png",
          //   name: "接单设置",
          //   path: "/pages/mine/acceptSetting"
          // },
          // {
          //   url: "../../static/images/s4.png",
          //   name: "客服电话"
          // },
          // {
          //   url: "../../static/images/s5.png",
          //   name: "使用协议",
          //   path: "/pages/mine/useXiyi"
          // },
          // {
          //   url: "../../static/images/s6.png",
          //   name: "关于",
          //   path: "/pages/mine/about"
          // },
          // {
          //   url: "../../static/images/s7.png",
          //   name: "设置",
          //   path: "/pages/mine/setting"
          // },
          {
            url: "../../static/images/s3.png",
            name: "退出登录",
            hidden: false
          },
        ],
        userInfo: {
          phone: ""
        }
      }
    },
    onShow() {
      this.getUserInfo();
    },
    methods: {
      toPage(item) {
        // if (item.name == "成员管理") {
        //   uni.navigateTo({
        //     url: "/pages/home/sellerList"
        //   })
        // }
        if (item.name == "退出登录") {
          this.$refs.modal.open();
        }
        uni.navigateTo({
          url: item.path
        })
      },
      confirm() {
        uni.showToast({
          title: "退出成功",
          icon: 'none',
          mask: true,
          duration: 1500,
        })
        setTimeout(() => {
          uni.removeStorageSync("token");
          uni.removeStorageSync("userInfo");
          uni.reLaunch({
            url: "/pages/login/index"
          })
          this.$refs.modal.close();
        }, 1500)

      },
      getUserInfo() {
        reqApi.getUserInfo({}).then(res => {
          console.log("获取用户信息", res);
          this.userInfo = res.data;
          // 商务管理
          if (res.data.is_manage == 1) {
            this.settingList[1].hidden = false;
          }
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .mine {
    .mineBg {
      width: 100vw;
      height: 745rpx;
      position: relative;

      .mineBg-info {
        width: 100vw;
        height: 745rpx;
        position: absolute;
        z-index: 20;
        left: 0;
        top: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;

        .avatar {
          width: 190rpx;
          height: 190rpx;
          border-radius: 532rpx;
          border: 4rpx solid #FFFFFF;
        }

        .nikename {
          font-family: PingFang SC, PingFang SC;
          font-weight: bold;
          font-size: 36rpx;
          color: #FFFFFF;
          margin-top: 40rpx;
        }

        .moblie {
          font-family: Microsoft YaHei UI, Microsoft YaHei UI;
          font-weight: 400;
          font-size: 28rpx;
          color: #FFFFFF;
          margin-top: 16rpx;
        }
      }

      .mineBg-img {
        width: 100vw;
        height: 745rpx;
        position: absolute;
        z-index: 10;
        left: 0;
        top: 0;
      }
    }

    .mineInfo {
      background: #fff;
      border-radius: 40rpx;
      margin-top: -112rpx;
      position: relative;
      z-index: 50;

      .mineInfo-item {
        height: 112rpx;
        padding: 0 40rpx;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 2rpx solid #eee;

        .img1 {
          width: 40rpx;
          height: 40rpx;
        }

        .label {
          font-family: PingFang SC, PingFang SC;
          font-weight: 400;
          font-size: 28rpx;
          color: #333333;
          flex: 1;
          margin: 0 20rpx;
        }

        .img2 {
          width: 40rpx;
          height: 40rpx;
        }
      }
    }
  }
</style>